package com.scau.clothes.controller;

import com.scau.clothes.pojo.Clothes;
import com.scau.clothes.service.ClothesService;
import com.scau.clothes.service.MailService;
import com.scau.clothes.service.OrderService;
import com.scau.clothes.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Set;

@RestController
public class TestController {
    private static String HOT_SALE_CLOTHES = "HOT_SALE_CLOTHES";
    @Autowired
    ClothesService clothesService;
    @Autowired
    TestService testService;
    @Autowired
    StringRedisTemplate stringRedisTemplate;
    @Autowired
    MailService mailService;
    @Autowired
    OrderService orderService;
    @RequestMapping("test")
    public List<Object> test(){
        return stringRedisTemplate.opsForHash().values("CART"+1);
    }
    @RequestMapping("test/zset")
    @ResponseBody
    public String testZset(){
        List<Clothes> clothesByPage = clothesService.getClothesByPage(1, 1, 0);
        return clothesByPage.toString();
    }
    @RequestMapping("test/rabbit")
    @ResponseBody
    public void testrabbit(){
        testService.testRabbit();
    }
    @RequestMapping("test/mail")
    public void sendMail(){
        mailService.sendMail("506142519@qq.com","test","<h1>trest1"+'\n'+"6666</h1>");
    }
    @RequestMapping("test/orders")
    @ResponseBody
    public void getOrders(){
        System.out.println(orderService.getOrdersByUserId(2));
    }
}
